<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="/js/jquery.js"></script>
</head>
<body>

<div id = "J_avatar"></div>
员工名字:<div id = "J_name"> </div><br>
编号:<div id = "J_code"> </div>
手机号码:<div id = "J_phone"> </div>
职位:<div id = "J_roleName"> </div>
所属分组:<div id = "J_groupName"> </div>

<div id = "J_menu">
<li><a href="">客户</a></li>
</div>

<script>
    $(function(){
        getUserInfo();
    });

    function getUserInfo(){

        var id = "${uid}";
        var data = {id:id};
        var url = "/user/user_info";
        $.ajax({
            type: "POST",
            async: false,
            dataType: 'json',
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(data),
            url: url,
            success: function(res){
                if(res.code == 200){
                    var datas = res.data;
                    $("#J_name").append(datas.name);
                    $("#J_code").append(datas.code);
                    $("#J_phone").append(datas.phone);
                    $("#J_avatar").append("<img src='"+datas.avatar+"'>");
                    $("#J_roleName").append(datas.role_name);
                    $("#J_groupName").append(datas.group_name);
                }else{
                    alert(res.msg);
                }
            },
            error: function(){

            },
            complete: function(){
                getMenuList();
            }
        });
    }


    function getMenuList(){
        var data = {uid:"${uid}"};
        var url = "/permission/list";
        $.ajax({
            type: "POST",
            async: false,
            dataType: 'json',
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(data),
            url: url,
            success: function(res){
                console.log(res);
                if(res.code == 200){
                    var list = res.data.list;
                    for (var i =0 ;i<list.length; i++){
                       var html = "";
                       switch (list[i]['code']){
                           case 10001 : html ='<li><a href="">员工</a></li>'; break;
                           case 10002 : html ='<li><a href="">角色</a></li>'; break;
                           case 10006 : html ='<li><a href="">开单</a></li>'; break;
                           case 10004 : html ='<li><a href="">报备</a></li>'; break;
                           case 10007 : html ='<li><a href="">任务</a></li>'; break;
                           case 10008 : html ='<li><a href="">积分</a></li>'; break;
                           case 10010 : html ='<li><a href="">设置</a></li>'; break;
                       }
                       $("#J_menu").append(html);
                    }

                }else{
                    //alert(res.msg);
                }
            },
            error: function(){

            },
            complete: function(){
            }
        });
    }

</script>
</body>
</html>
